<template>
	
	<view class="user">
		<!-- 头部 -->
		<view class="user-wrap" :style="'background: url(' +  imgpath + 'luyi/unit/2023/11/01/3011.png);'">
			<view class="info">
        <view class="head-left">
          <image class="avatar" mode="aspectFill" src="https://pic1.zhimg.com/70/v2-54893828153341f05b9f24025369af44_1440w.image?source=172ae18b&biz_tag=Post"></image>
        </view>
        <view class="head-right">
          <view class="right-up">
            <view class="nickname">{{nickName}}</view>
            <view class="tips">{{identity}}</view>
          </view>
          <view class="right-bot">
            {{userMobile || ''}}
          </view>
        </view>
			</view>
		</view>
    
		<!-- 用户服务 -->
		<view class="com-item">
			<view class="com-wrap">
				<view class="cell">
					<view class="cell-left">
						<view class="cell-text" style="font-weight: 600;">服务中心</view>
					</view>
				</view>
				<view class="cell" v-for="(item, index) in serverList" :key="index" @click="jon(item.path)">
					<view class="cell-left">
						<image class="cell-icon" :src="item.icon" mode="aspectFill"></image>
						<view class="cell-text">{{ item.title }}</view>
					</view>
					<view class="iconfont iconmore1"></view>
				</view>
			</view>
		</view>

	</view>
</template>

<script> 
export default {
	data() {
		return {
      imgpath: this.imgpath,
      nickName: '用户昵称',
			currentIndex: 0,
      identity: null,
			serverList: [
				{
					title: '个人中心',
					icon: '/static/images/person.png',
					path: '/pages/example/personmanage/selectperson?openType=' + 0
				},
			
				{
					title: '签约信息',
					icon: '/static/images/contract.png',
					path: '/pages/example/contract/signing'
				},
				{
					title: '退出登录',
					icon: '/static/images/loginout.png',
					path: '/pages/example/login/index'
				}
			]
		};
	},
	onLoad() {
		uni.hideShareMenu();
	},
	onShow() {
		
	},
	methods:{
		Jom(path){
			let rz=uni.getStorageSync('userData').rz;
			if(rz==0){

			}else{
				uni.$u.route({
					url: path
				})
			}
		},
		user(){
			uni.$u.route({
				url: "/pages/componentsC/user/user"
			})
		},
		jon(path){
			console.log(path)
      if(path.indexOf('index') != -1){
        //判断点击的是退出按钮
        let userNumber = uni.getStorageSync('userNumber')
        uni.clearStorageSync()
        uni.setStorageSync('userNumber',userNumber)
        console.log('clear token');
        uni.reLaunch({
          url: '/pages/example/login/index'
        })
      }
      if(path.indexOf('selectperson') != -1){
        uni.navigateTo({
          url: path
        })
      }
      if(path.indexOf('signing') != -1){
        uni.navigateTo({
          url: path
        })
      }
      
      

		}
	},
  created() {
    
    this.nickName = uni.getStorageSync('nickName')
    this.userMobile = uni.getStorageSync('userMobile')
    console.log(uni.getStorageSync('nickName'));
    let usertype = uni.getStorageSync('usertype')
    if(usertype == 1){
      this.identity = '超级管理员'
    }else if(usertype == 2){
      this.identity = '劳资专员-项目' 
    }else if(usertype == 3){
      this.identity = '包工头'
    }else if(usertype == 4){
      this.identity = '劳工'
    }else if(usertype == 5){
      this.identity = '劳资专员-个人'
    }
    
  }
};
</script>

<style lang="scss">
  .cell{
    // margin: 10rpx 0;
    padding: 10rpx 10rpx;
  }
  
  .info{
    display: flex;
    width: 100%;
    .head-left{
      .avatar{
        width: 155rpx;
        height: 155rpx;
      }
      padding-left: 40rpx;
    }
    .head-right{
      padding-left: 30rpx;
      padding-top: 30rpx;
      display: flex;
      flex-direction: column;
      .right-up{
        display: flex;
        align-items: center;
        .tips{
          padding: 0 24rpx;
          font-size: 24rpx;
          width: fit-content;
          height: 36rpx;
          display: flex;
          justify-content: center;
          align-items: center;
          background-color: #F8F8F8;
          color: #055DFE;
          border-radius: 18rpx;
          margin-left: 19rpx;
        }
        .nickname{
          font-size: 28rpx;
          color: white;
        }
      }
      .right-bot{
        font-size: 28rpx;
        text-align: left;
        color: white;
      }
    }
  }
  
page {
	background: #f2f2f2;
}
.btn-hover {
	// background: #f2f2f2 !important;
  // background: url('/static/images/3011.png');
  background: url('https://www.toopic.cn/public/uploads/small/1658043938262165804393852.jpg');
}

</style>
